package down.xiaoheihe.work.utils;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ElasticsearchConfig {
    @Bean
    public RestHighLevelClient restHighLevelClient() {
        //连接本地的ElasticSearch
        return new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("localhost", 9200, "http")
                ));
//        连接服务器的ElasticSearch
//        return new RestHighLevelClient(
//                RestClient.builder(
//                        new HttpHost("175.178.4.131", 9200, "http")
//                ));
        //连接虚拟机的ElasticSearch
//        return new RestHighLevelClient(
//        RestClient.builder(
//        new HttpHost("192.168.59.129", 9200, "http")
//        ));

    }
}
